package com.tencent.mm.opensdk.modelbiz;

import android.os.Bundle;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.utils.Log;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONStringer;
import org.json.JSONTokener;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class AddCardToWXCardPackage
{
  private static final String TAG = "MicroMsg.AddCardToWXCardPackage";
  
  public static class Resp
    extends BaseResp
  {
    public List<AddCardToWXCardPackage.WXCardItem> cardArrary;
    
    public Resp() {}
    
    public Resp(Bundle paramBundle)
    {
      fromBundle(paramBundle);
    }
    
    public int getType()
    {
      return 9;
    }
    
    public boolean checkArgs()
    {
      return (this.cardArrary != null) && (this.cardArrary.size() != 0);
    }
    
    public void toBundle(Bundle paramBundle)
    {
      super.toBundle(paramBundle);
      JSONStringer localJSONStringer = new JSONStringer();
      try
      {
        localJSONStringer.object();
        localJSONStringer.key("card_list");
        localJSONStringer.array();
        Iterator localIterator = this.cardArrary.iterator();
        while (localIterator.hasNext())
        {
          AddCardToWXCardPackage.WXCardItem localWXCardItem = (AddCardToWXCardPackage.WXCardItem)localIterator.next();
          localJSONStringer.object();
          localJSONStringer.key("card_id");
          localJSONStringer.value(localWXCardItem.cardId);
          localJSONStringer.key("card_ext");
          localJSONStringer.value(localWXCardItem.cardExtMsg == null ? "" : localWXCardItem.cardExtMsg);
          localJSONStringer.key("is_succ");
          localJSONStringer.value(localWXCardItem.cardState);
          localJSONStringer.endObject();
        }
        localJSONStringer.endArray();
        localJSONStringer.endObject();
      }
      catch (Exception localException)
      {
        Log.e("MicroMsg.AddCardToWXCardPackage", "Resp.toBundle exception:" + localException.getMessage());
      }
      paramBundle.putString("_wxapi_add_card_to_wx_card_list", localJSONStringer.toString());
    }
    
    public void fromBundle(Bundle paramBundle)
    {
      super.fromBundle(paramBundle);
      if (this.cardArrary == null) {
        this.cardArrary = new LinkedList();
      }

      String s=paramBundle.getString("_wxapi_add_card_to_wx_card_list");

      if ((s!= null) && (s.length() > 0)) {
        try
        {
          JSONArray    jsonObject = ((JSONObject)new JSONTokener(s).nextValue()).getJSONArray("card_list");
          for (int i = 0; i < jsonObject.length(); i++)
          {
            JSONObject localJSONObject = jsonObject.getJSONObject(i);
            AddCardToWXCardPackage.WXCardItem localWXCardItem;
            (localWXCardItem = new AddCardToWXCardPackage.WXCardItem()).cardId = localJSONObject.optString("card_id");
            localWXCardItem.cardExtMsg = localJSONObject.optString("card_ext");
            localWXCardItem.cardState = localJSONObject.optInt("is_succ");
            this.cardArrary.add(localWXCardItem);
          }
          return;
        }
        catch (Exception localException) {}
      }
    }
  }
  
  public static class Req
    extends BaseReq
  {
    public List<AddCardToWXCardPackage.WXCardItem> cardArrary;
    
    public int getType()
    {
      return 9;
    }
    
    public boolean checkArgs()
    {
      if ((this.cardArrary == null) || (this.cardArrary.size() == 0) || (this.cardArrary.size() > 40)) {
        return false;
      }
      Iterator localIterator = this.cardArrary.iterator();
      while (localIterator.hasNext())
      {
        AddCardToWXCardPackage.WXCardItem localWXCardItem;
        if (((localWXCardItem = (AddCardToWXCardPackage.WXCardItem)localIterator.next()) == null) || (localWXCardItem.cardId == null) || (localWXCardItem.cardId.length() > 1024) || ((localWXCardItem.cardExtMsg != null) && (localWXCardItem.cardExtMsg.length() > 1024))) {
          return false;
        }
      }
      return true;
    }
    
    public void toBundle(Bundle paramBundle)
    {
      super.toBundle(paramBundle);
      JSONStringer localJSONStringer = new JSONStringer();
      try
      {
        localJSONStringer.object();
        localJSONStringer.key("card_list");
        localJSONStringer.array();
        Iterator localIterator = this.cardArrary.iterator();
        while (localIterator.hasNext())
        {
          AddCardToWXCardPackage.WXCardItem localWXCardItem = (AddCardToWXCardPackage.WXCardItem)localIterator.next();
          localJSONStringer.object();
          localJSONStringer.key("card_id");
          localJSONStringer.value(localWXCardItem.cardId);
          localJSONStringer.key("card_ext");
          localJSONStringer.value(localWXCardItem.cardExtMsg == null ? "" : localWXCardItem.cardExtMsg);
          localJSONStringer.endObject();
        }
        localJSONStringer.endArray();
        localJSONStringer.endObject();
      }
      catch (Exception localException)
      {
        Log.e("MicroMsg.AddCardToWXCardPackage", "Req.toBundle exception:" + localException.getMessage());
      }
      paramBundle.putString("_wxapi_add_card_to_wx_card_list", localJSONStringer.toString());
    }
  }
  
  public static final class WXCardItem
  {
    public String cardId;
    public String cardExtMsg;
    public int cardState;
  }
}



/* Location:           C:\Users\Mr Ding\Desktop\Android_SDK_5.0.6\libs\wechat-sdk-android-without-mta-1.3.4.jar

 * Qualified Name:     com.tencent.mm.opensdk.modelbiz.AddCardToWXCardPackage

 * JD-Core Version:    0.7.0.1

 */